Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "type": "module" to package.json #309

Merged

Conversation

antoninbas
Copy link
Contributor

It ensures that the ESM build of Vite is used instead of the CJS build (deprecated). See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated

This is also consistent with the Vite React templates: https://github.com/vitejs/vite/blob/cdc664d4ea98d5373c3ceb2213771f1dfa4bb457/packages/create-vite/template-react-ts/package.json#L5

Because we were using TypeScript to begin with (and therefore the ESM syntax for import/export), no change is required in source files.

Note that because ESM ("es") was already the default output format for rollupjs, I don't think there is any difference in the final app (index.html was already using <script type="module">). So in essence, this change is really about avoiding the deprecation warning from Vite.

It ensures that the ESM build of Vite is used instead of the CJS build
(deprecated). See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated

This is also consistent with the Vite React templates:
https://github.com/vitejs/vite/blob/cdc664d4ea98d5373c3ceb2213771f1dfa4bb457/packages/create-vite/template-react-ts/package.json#L5

Because we were using TypeScript to begin with (and therefore the ESM
syntax for import/export), no change is required in source files.

Note that because ESM ("es") was already the default output format for
rollupjs, I don't think there is any difference in the final app
(index.html was already using `<script type="module">`). So in essence,
this change is really about avoiding the deprecation warning from Vite.

.eslintrc.js had to be renamed to .eslintrc.cjs. ESLint currently does
not support ESM configuration.

Signed-off-by: Antonin Bas <[email protected]>
@antoninbas antoninbas force-pushed the add-type-module-to-package-json branch from 166ec95 to 476d274 Compare March 25, 2024 23:41
@antoninbas antoninbas merged commit 631093e into antrea-io:main Mar 25, 2024
11 checks passed
@antoninbas antoninbas deleted the add-type-module-to-package-json branch March 25, 2024 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant